﻿using System.Diagnostics;

namespace LEE.Tools.Others
{
    public class ProcessHelper
    {
        /// <summary>
        /// 执行外部文件
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public static bool Execute(string fileName, string arguments)
        {
            var psi = new ProcessStartInfo(fileName, arguments)
            {
                UseShellExecute = false,
                CreateNoWindow = true,
                WindowStyle = ProcessWindowStyle.Hidden
            };
            var proc = Process.Start(psi);
            if (proc == null) return false;
            proc.WaitForExit();
            var exit = proc.HasExited;
            proc.Dispose();
            proc.Close();
            return exit;
        }
    }
}
